#include "..\inc\swilib.h"
//#include "ft_cache.h"
#include "ft_font.h"

typedef struct{
  TT_Char* node;
  short symb;
  void* next;
}TTC_Char;

TTC_Char* TTChar_top = 0;

TT_Char* TTC_RequestChar(short symb)
{
  TTC_Char* tt_symb = TTChar_top;
  while(tt_symb)
  {
    if(tt_symb->symb == symb) return tt_symb->node;
    tt_symb = tt_symb->next;
  }
  TT_Char* node;
  if(!(node = GetChar(symb))) return 0;
  tt_symb = malloc(sizeof(TTC_Char));
  tt_symb->symb = symb;
  tt_symb->next = TTChar_top;
  tt_symb->node = node;
  TTChar_top = tt_symb;
  return tt_symb->node;
}

void TT_FreeCache()
{
  while(TTChar_top)
  {
    TTC_Char* tt_symb = TTChar_top;
    TTChar_top = TTChar_top->next;
    mfree(tt_symb->node->bitmap);
    mfree(tt_symb->node);
    mfree(tt_symb);
  }
}
